<template>
  <div>子组件</div>
  <Grandson></Grandson>
</template>

<script setup>
import Grandson from "./Grandson.vue";
import { inject } from "vue";
// 语法: const 变量名 = inject('祖先组件提供的属性名)
const username = inject("usernameprop");

// 注入根数据
const rootmsg = inject("rootprop");
console.log("rootmsg", rootmsg);

console.log("username", username);
</script>
<style scoped>
</style>